package com.yonyou.isv.demo.openapi.api.tax;

import com.yonyou.isv.demo.openapi.api.BaseOpenApi;
import com.yonyou.isv.demo.openapi.api.OpenApiURL;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataArrayResponse;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataResponse;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 销项开票(扫码开票、发票打印、开票申请、红字信息表)
 * @Author jiaogjin
 * @Date 2022/4/25 9:24
 **/
@Component
public class InvoiceApplyApi extends BaseOpenApi {

    /**
     * 销项开票-扫码开票
     * @author jiaogjin
     * @date 2022/4/25 9:37
     * @param params
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     */
    public Map<String,Object> insertForQRInvoice(Map<String, Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.INSERT_FOR_QR_INVOICE, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 销项开票-发票打印
     * @author jiaogjin 
     * @date 2022/4/25 14:15 
     * @param params
     * @return null 
     */
    public Map<String,Object> print(Map<String, Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.INVOICE_PRINT, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 功能描述: 开票状态查询
     * @Author: jiaoguojin
     * @Date: 2022/7/6 10:08
     */
    public Map<String,Object> queryInvoiceStatus(Map<String, Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.QUERY_INVOICE_STATUS, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-开蓝票
     * @author jiaogjin
     * @date 2022/4/25 10:12
     * @param params
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     */
    public Map<String,Object> insertWithArray(Map<String, Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.INSERT_WITH_ARRAY, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-开蓝票-自动拆分
     * @author jiaogjin 
     * @date 2022/4/25 15:59
     * @param params
     * @return null 
     */
    public List<Map<String,Object>> insertWithSplit(Map<String, Object> params)
    {
        ApiDataArrayResponse apiDataResponse = postForEntityByForm(OpenApiURL.INSERT_WITH_SPLIT, params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-审核通过
     * @author jiaogjin 
     * @date 2022/4/25 16:07
     * @param params
     * @return null 
     */
    public Map<String,Object> issue(Map<String, Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.ISSUE, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-发票红冲请求
     * @author jiaogjin
     * @date 2022/4/25 16:37
     * @param null
     * @return null
     */
    public Map<String, Object> red(Map<String, Object> params) {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.RED, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-电子发票部分红冲
     * @author jiaogjin
     * @date 2022/4/25 16:42
     * @param null
     * @return null
     */
    public Map<String, Object> partRed(Map<String, Object> params) {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.PART_RED, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-重发邮件
     * @author jiaogjin
     * @date 2022/4/25 16:48
     * @param null
     * @return null
     */
    public Map<String, Object> callBackByEmail(Map<String, Object> params,String url) {
        ApiDataResponse apiDataResponse = postForEntityByForm(url, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-删除开票失败申请
     * @author jiaogjin
     * @date 2022/4/25 18:11
     * @param null
     * @return null
     */
    public Map<String, Object> deleteInvoiceFailData(Map<String, Object> params) {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.DELETE_INVOICE_FAILDATA, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 开票申请-开票申请删除
     * @author jiaogjin
     * @date 2022/4/26 10:35
     * @param null
     * @return null
     */
    public Map<String, Object> del(Map<String, Object> params) {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.DEL_INVOICE_APPLY, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 发票作废-纸质发票作废
     * @author jiaogjin 
     * @date 2022/4/25 18:13
     * @param null 
     * @return null 
     */
    public Map<String, Object> invalid(Map<String, Object> params) {
        ApiDataResponse apiDataResponse = postForEntityByForm(OpenApiURL.PAPER_INVOICE_INVALID, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 红字信息表-红字信息表编号查询
     * @author jiaogjin
     * @date 2022/4/26 10:27
     * @param null
     * @return null
     */
    public Map<String, Object> queryRedInfoApply(String url) {
        ApiDataResponse apiDataResponse = getForEntity(url, new HashMap<>(), ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 红字信息表-申请红字信息表（购方销方）
     * @author jiaogjin
     * @date 2022/4/26 10:27
     * @param null
     * @return null
     */
    public Map<String, Object> insertWithRedApply(Map<String, Object> params) {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.INSERT_WITH_RED_APPLY, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
}
